Xbasic

json_validate Function

Syntax

json_validate(c jsonText)

Arguments

jsonTextCharacter

The JSON text to validate.

Description

Returns an empty string if the JSON is valid. Otherwise it returns an error message to tell you what is wrong with the JSON.

Example

dim json as c =<<%json%
{
   "schema" : {
      "name" : { "type" : "C" , "width": 30 }, 
      image : { "type" : "Png" }
    },
    "data": 
       [
          {"name":"John Smith", "image" : "iVBORw...(data truncated for readability)....AAAElFTkSuQmCC" },
          {"name":"Jane Smith", "image" : "data:image/bmp;base64,Qk02AwAAA...(data truncated for readability)....AAAADYAAAAAA=="}
       ]
}
%json%

? json_validate(json)
= "Name of an object member must be a string"

See Also